package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface BrandMapper extends Mapper<Brand> {

    /**
     * 根据分类名称获取到品牌列表信息
     * @param categoryName
     * @return
     */
    @Select("select b.name name,b.image image from tb_brand b,tb_category c,tb_category_brand cb where cb.category_id = c.id and cb.brand_id = b.id and c.name = #{name}")
    //@Select("select name,image from tb_brand where id in(select brand_id from tb_category_brand WHERE category_id IN (select id from tb_category WHERE name = #{name} ))")
    List<Map> findBrandListByCategory(@Param("name") String categoryName);
}
